package com.example.shopping.service.impl;

import com.example.shopping.mapper.OrdersMapper;
import com.example.shopping.service.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description: TODO
 * @author: uu
 * @data: 2023/6/29 20:31
 * @version: v1.0
 */
@Service
public class OrdersImpl implements Orders {
    @Autowired
    OrdersMapper mapper;
    @Override
    public Boolean update(com.example.shopping.pojo.Orders orders) {

        int update = mapper.update(orders);
        return update == 1 ? true : false;
    }

    @Override
    public List<com.example.shopping.pojo.Orders> findById(Integer a, Integer id) {
        if (a == 1){
            List<com.example.shopping.pojo.Orders> byCustomerId = mapper.findByCustomerId(id);
            return byCustomerId;
        }
        List<com.example.shopping.pojo.Orders> byMerchantId = mapper.findByMerchantId(id);
        return byMerchantId;
    }

    @Override
    public Boolean save(com.example.shopping.pojo.Orders orders) {
        int insert = mapper.insert(orders);
        return insert == 1 ? true : false;
    }

}
